package com.itboye.qihang;

import android.app.Application;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.itboye.qihang.consts.UserConst;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;


public class MyApplication extends Application {

    public static MyApplication instatnce;

    private static RequestQueue queue;


    // IWXAPI 是第三方app和微信通信的openApi接口
    public static IWXAPI api;

    @Override
    public void onCreate() {
        super.onCreate();

        inJectWX();
    }

    private void inJectWX() {

        // 通过WXAPIFactory工厂，获取IWXAPI的实例
        api = WXAPIFactory.createWXAPI(this, UserConst.WXAPPID, true);

        // 将应用的appId注册到微信
        api.registerApp(UserConst.WXAPPID);

    }

    public static MyApplication getInstance() {

        return instatnce;

    }

    /**
     * @return the queue
     */
    public static RequestQueue getQueue() {
        return queue;
    }

    //
    public static <T> void addRequest(Request<T> request) {
        request.addMarker("itboye");
        getQueue().add(request);
    }
}
